from django.db import models
from datetime import datetime

# Create your models here.

class Author(models.Model):
    name = models.CharField(max_length=50)
    email = models.EmailField(blank=True)

    def __unicode__(self):
        return self.name

class Category(models.Model):
    name = models.CharField(max_length=50,default="Other")
    def __unicode__(self):
        return self.name

class Tag(models.Model):
    name=models.CharField(max_length=20)
    def __unicode__(self):
        return self.name

class Entry(models.Model):
    title       = models.CharField(max_length=200)
    authors     = models.ForeignKey(Author)
    body_text   = models.TextField()
    pub_date    = models.DateTimeField(default=datetime.now)
#    mod_date    = models.DateTimeField()
    n_comments = models.IntegerField(default=0)
    n_pingbacks = models.IntegerField(default=0)
    rating = models.IntegerField(default=0)
    category   = models.ForeignKey(Category)
    tag        = models.ManyToManyField(Tag,blank=True)


    def __unicode__(self):
        return self.title

class About(models.Model):
    text=models.TextField()
        
